Page({

  /**
   * 页面的初始数据
   */
data: {
    ModelShow:true,
    SwiperList:[],
    product:[]
  },
//弹窗
onSwiperBookBtnclick(){
    this.setData({
      ModelShow: true
    })
  },
  //跳转
  clickprotocol(e){
    console.log(e.currentTarget.dataset.id);
wx.navigateTo({
  url: '/pages/protocol/index?id=' + e.currentTarget.dataset.id,
})
  this.setData({ModelShow:false})
  },
  /**
   * 生命周期函数--监听页面加载
   */
  // SwiperChange(e){
  //   const {current} =e.detail
  //   this.setData({
  //     currentSwiperactive:current    
  //   })
  // },
onLoad: function (options) {
    const db = wx.cloud.database()
    this._loadSwiper(db)  
    this.getDataproduct(db)
  },
  getDataproduct(db){
db.collection('product').get().then(res =>{
  console.log(res.data);
  const product = res.data
  this.setData({
    product
  })
})
  },
_loadSwiper(db){
    // wx.cloud.database().collection
 db.collection('Swiper').get().then(res=>{
  res.data.forEach((item,index)=>{
    item.config.forEach((item2,index) =>{
      let splitList = item2.split('|')
     item.config[index] = {title:splitList[0],subtitle:splitList[1]}
  })
    res.data[index] =item
  })
  
this.setData({
    SwiperList:res.data
  })
})
  },
})